package com.jinbei.restController;

import com.jinbei.common.annotation.AuthorAnnotation;
import com.jinbei.common.base.ResponseBase;
import com.jinbei.common.base.ResponseBaseEntity;
import com.jinbei.domain.Dept;
import com.jinbei.service.DeptService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zflu
 * 部门 restful 接口
 * Created by lucky on 2018/8/9.
 */
@RestController
@RequestMapping("/dept")
public class DeptController {

    private final Logger logger = LoggerFactory.getLogger(DeptController.class);

    @Autowired
    private DeptService deptService;

    /**
     * @author zflu
     * @Description   部门列表查询
     * @date 2018/8/9 10:11
     * @param
     * @return com.jinbei.common.base.ResponseBase
     */
    @AuthorAnnotation(name="/dept/queryDeptList" ,logs = "部门列表查询")
    @GetMapping("/queryDeptList")
    public ResponseBase queryCourseByType(){
        try {
            List<Dept> deptList = deptService.queryDeptList();
            return ResponseBaseEntity.setResultSuccess(deptList);
        }catch (Exception e){
            logger.error("部门列表查询失败!  {}",e);
            return ResponseBaseEntity.setResultError(null);
        }
    }
}
